@isTest
private class CountTheLowerPriceHandlerTest {
	

    //报价/调价
    static testMethod void testMethod2() {
        
        //客户1
        Account acc = TestUtils.createAccount();
        acc.Level__c = '三级甲等';
        insert acc;     

        //业务机会1
        Opportunity opp = TestUtils.createOpportunity();
        opp.AccountId = acc.Id;
        insert opp;

        //报价2
        Quote qt2 = new Quote(Name = '试剂报价',Type__c = '试剂报价',OpportunityId = opp.Id);
        insert qt2 ;

        //调价
        AdjustPrice__c ap = new AdjustPrice__c();
        ap.Account__c = acc.Id;
        ap.SalesCode__c = '05';
        insert ap;

       

        //产品1 
        List<Product__c> plist =new List<Product__c>();
        List<QuoteProduct__c> quoteList = new List<QuoteProduct__c>();
        Id pRT = Utils.getRecordTypeIdByDevNameAndObjName('NCProduct', 'Product__c');
        Set<String> cates = new Set<String>{'免疫','病理','生化','血糖','血液','血型','分子'};
        for (String cate  : cates) {
          	Product__c p1 = TestUtils.createProduct();
	        p1.Name = 'Test'+cate;
	        p1.Category1__c = cate; 
	        p1.RecordTypeId = pRT;

	        plist.add(p1);

         }  


      	     
         User u = [select Id,PriceProvince__c from User where Id=:UserInfo.getUserId()];

        insert plist;

        List<Price__c> priceList =new List<Price__c>();
        List<AdjustPriceProduct__c> appList =new List<AdjustPriceProduct__c>();
        for (Product__c p :  plist) {
        	Price__c price2 = TestUtils.createPrice();
	        price2.Product__c = p.Id;
	        price2.Company__c = '四川省迈克实业有限公司';
	        price2.InstCost__c = 10.0;
	        price2.HospitalManagerPrice__c = 10;
	        price2.InvoiceDealerPrice__c = 10;
	        price2.SpecialPrice__c = 10;
	        price2.ProvincialAgencyPrice__c = 10;
            price2.Province__c =u.PriceProvince__c;

	        priceList.add(price2);
	        quoteList.add(new QuoteProduct__c(Name = '测试报价产品2',Product__c = p.Id,Quote__c = qt2.Id,SalesPrice__c = 5));

	         AdjustPriceProduct__c app = new AdjustPriceProduct__c();
	        app.AdjustPrice__c = ap.Id;
	        app.Product__c = p.Id;
	        app.OriginalPrice__c = 1;
	        app.AdjustSalesPrice__c = 2;

	        appList.add(app);
        
        }

        
        insert priceList;   

        insert quoteList;



        qt2.Status = '申请中';
        update qt2;  


        insert appList;

        ap.Status__c = '已提交';
        update ap ;  




     



    }
}